// CDQ
// https://www.luogu.com.cn/problem/P3810
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
using namespace std;
using ll = long long;
using T = int;
T rad(); // quick read
const int inf = 0x3f3f3f3f;
#define rf(i, n) for (int i = 1; i <= (n); ++i)
const int max_size = 5 + 2e5;
const int maxn = 5 + 1e5;

struct BIT {
    int val[max_size];
    void update(int i, int x) {
        while (i < max_size) val[i] += x, i += i & -i;
    }

    int ask(int i) {
        int ret = 0;
        while (i > 0) ret += val[i], i -= i & -i;
        return ret;
    }
} bt;

struct Node {
    int x, y, z;
    bool operator<(const Node &r) const {
        if (x != r.x) return x < r.x;
        if (y != r.y) return y < r.y;
        return z < r.z;
    }
} a[maxn];
int f[maxn];

int n, k; // 数量，值域
int id[maxn];
bool cmp(int i, int j) {
    if (a[i].y != a[j].y) return a[i].y < a[j].y;
    return i < j; // 不严格偏序对，相等时第一分量小的优先
}

void cdq(int l, int r) {
    if (l == r) return;
    int mid = l + r >> 1;
    cdq(l, mid);

    for (int i = l; i <= r; ++i) id[i] = i;
    sort(id + l, id + r + 1, cmp);
    for (int j = l; j <= r; ++j) {
        int i = id[j];
        if (i <= mid) // 左边维护数据
            bt.update(a[i].z, 1);
        else // 右边统计
            f[i] += bt.ask(a[i].z);
    }

    // 清空树状数组
    for (int j = l; j <= r; ++j) {
        int i = id[j];
        if (i <= mid) bt.update(a[i].z, -1);
    }
    cdq(mid + 1, r);
}

int ans[maxn];

int main() {
    n = rad(), k = rad();
    rf(i, n) a[i].x = rad(), a[i].y = rad(), a[i].z = rad();
    sort(a + 1, a + 1 + n);
    cdq(1, n);
    // rf(i, n) printf("%d ", f[i]);
    map<Node, int> visit;
    for (int i = n; i > 0; --i) visit.count(a[i]) ? f[i] = visit[a[i]] : visit[a[i]] = f[i];
    rf(i, n) ans[f[i]]++;
    for (int i = 0; i < n; ++i) printf("%d\n", ans[i]);
}

T rad() {
    T back = 0;
    int ch = 0, posi = 0;
    for (; ch < '0' || ch > '9'; ch = getchar())
        posi = ch ^ '-';
    for (; ch >= '0' && ch <= '9'; ch = getchar())
        back = (back << 1) + (back << 3) + (ch & 0xf);
    return posi ? back : -back;
}